home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
8_6.lha
/
8_6
/
8_6_stream.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
1KB
|
62 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ Exercise 8.6
/ <streambuf.h>
/ Implementation of stream I/O
/ using the standard I/O functions.
ifndef STREAMBUF_H
define STREAMBUF_H
/ a buffer for streams
lass streambuf
char alloc; // buffer was allocated
riend filebuf;
rotected:
char *base; // beginning of buffer
char *pptr; // next free byte
char *gptr; // next filled byte
char *eptr; // first byte following buffer
// allocate some space for the buffer
int doallocate();
ublic:
streambuf();
streambuf(char* p, int l);
~streambuf();
// Empty the buffer. Return EOF on error,
// 0 on success.
virtual int overflow(int c = EOF);
// Fill a buffer. Return EOF on error
// or end of input, else the next character
virtual int underflow();
// get the current character or EOF
int sgetc();
// get the next character
int snextc();
// advance to the next character
void stossc();
// Return a character to the buffer.
void sputbackc(char c);
// put a character into the buffer
int sputc(int c = EOF);
// supply an area for a buffer.
streambuf *setbuf(char *p, int len, int count =0);
// check the buffer and allocate if necessary
int allocate();
;
endif /* STREAMBUF_H */